package br.com.tcc.systemdx.persistence.hibernate;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.tcc.systemdx.commons.persistence.CriteriaTransformer;
import br.com.tcc.systemdx.domain.Sintoma;
import br.com.tcc.systemdx.persistence.SintomaDAO;

@Repository(SintomaDAO.BEAN_NAME)
@Transactional
public class SintomaHibernateDAOImpl extends
		AbstractEntityHibernateDAOImpl<Sintoma> implements SintomaDAO {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1155934130777682234L;

	public List<Sintoma> findByAtributoIdEValorId(Long atributoId, Long valorId) {
		CriteriaTransformer criteriaTransformer = new CriteriaTransformer() {
			
			public Criteria transformCriteria(Criteria criteria) {
				criteria.createAlias("atributo", "atributo").createAlias("valor", "valor");
				return criteria;
			}
		};
		
		return findByCriteria(criteriaTransformer, Restrictions.and(Restrictions.eq("atributo.id", atributoId), Restrictions.eq("valor.id", valorId)));
	}
	
	
}
